////
////  ScanView.m
////  MyFunctionDemo
////
////  Created by Ting Han on 2017/8/29.
////  Copyright © 2017年 Ting Han. All rights reserved.
////
//
//#import "HTMScanView.h"
//#import <QuartzCore/QuartzCore.h>
//
//#define kArrorHeight    kHeight(80)
//
//@interface HTMScanView ()
//
//@property (nonatomic,weak) UIView *childView;
//@property (nonatomic,weak) UIButton *topBtn;
//
//@end
//
//@implementation HTMScanView
//
//- (id)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        self.backgroundColor = [UIColor clearColor];
//        self.type = ScanViewPositionUp;
//        [self setupView];
//    }
//    return self;
//}
//#pragma mark --- 界面绘制
//- (void)setupView{
//    UIButton *topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    topBtn.frame = CGRectMake(0, 0, 50, 50);
//    topBtn.center = CGPointMake(self.centerX, topBtn.centerY);
//    [self addSubview:topBtn];
//    topBtn.backgroundColor = [UIColor clearColor];
//    [topBtn addTarget:self action:@selector(didClickTopBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [topBtn setImage:[UIImage imageNamed:@"icon_down"] forState:UIControlStateNormal];
//    [topBtn setImage:[UIImage imageNamed:@"icon_down_highlited"] forState:UIControlStateHighlighted];
//    self.topBtn = topBtn;
//    UIView *childView = [[UIView alloc]initWithFrame:CGRectMake(0, kArrorHeight-kHeight(20), self.width, self.height-kArrorHeight+kHeight(20))];
//    childView.backgroundColor = [UIColor whiteColor];
//    [self addSubview:childView];
//    self.childView = childView;
//    
//    UISwipeGestureRecognizer *up = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handlerSwipeGesture:)];
//    [up setDirection:UISwipeGestureRecognizerDirectionUp];
//    [self addGestureRecognizer:up];
//    UISwipeGestureRecognizer *down = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handlerSwipeGesture:)];
//    [down setDirection:UISwipeGestureRecognizerDirectionDown];
//    [self addGestureRecognizer:down];
//
//    [self addSaoyisaoButton];
//    [self addLocationBtn];
//    [self addBalanceButton];
//    
//}
////扫一扫按钮
//- (void)addSaoyisaoButton{
//    self.saoyisaoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.childView addSubview:self.saoyisaoBtn];
//    [_saoyisaoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.childView.mas_centerX);
//        make.top.mas_equalTo(0);
//        make.width.mas_equalTo(kHeight(130));
//        make.height.mas_equalTo(kHeight(130));
//    }];
//    [_saoyisaoBtn setBackgroundImage:[UIImage imageNamed:@"zhuye_saoyisao"] forState:UIControlStateNormal];
//    //[_saoyisaoBtn setImage:[UIImage imageNamed:@"zhuye_saoyisao"] forState:UIControlStateNormal];
//}
////余额按钮
//- (void)addBalanceButton{
//    self.balanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.childView addSubview:self.balanceBtn];
//    [self.balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(-10);
//        make.bottom.mas_equalTo(-10);
//        make.width.mas_equalTo(68);
//        make.height.mas_equalTo(68);
//    }];
//    [self.balanceBtn setImage:[UIImage imageNamed:@"zhuye_yuer"] forState:UIControlStateNormal];
//    
//}
////定位按钮
//- (void)addLocationBtn{
//    UIButton* localtionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.childView addSubview:localtionBtn];
//    
//    localtionBtn.frame = CGRectMake(self.saoyisaoBtn.frame.origin.x/2.0 - 15, self.saoyisaoBtn.frame.origin.y, 30, 30);
//    [localtionBtn setImage:[UIImage imageNamed:@"icon_location_unselected"] forState:UIControlStateNormal];
//    [localtionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(10);
//        make.bottom.mas_equalTo(-10);
//        make.width.mas_equalTo(68);
//        make.height.mas_equalTo(68);
//        
//    }];
//    self.locationBtn = localtionBtn;
//}
//#pragma mark --- 事务处理
//- (void)handlerSwipeGesture:(UISwipeGestureRecognizer *)sender{
//    if (sender.direction == UISwipeGestureRecognizerDirectionDown) {
//        [self setViewDown];
//    }
//    if (sender.direction == UISwipeGestureRecognizerDirectionUp) {
//        [self setViewUp];
//    }
//}
//- (void)didClickTopBtn:(UIButton *)sender{
//    switch (self.type) {
//        case ScanViewPositionUp:
//        {
//            [self setViewDown];
//            
//        }
//            break;
//        case ScanViewPositionDown:
//        {
//            [self setViewUp];
//        }
//        default:
//            break;
//    }
//}
//
//- (void)setViewUp{
//    if (self.type == ScanViewPositionUp) {
//        return;
//    }
//    self.type = ScanViewPositionUp;
//    [_topBtn setImage:[UIImage imageNamed:@"icon_down"] forState:UIControlStateNormal];
//    [_topBtn setImage:[UIImage imageNamed:@"icon_down_highlited"] forState:UIControlStateHighlighted];
//
//    self.childView.hidden = NO;
//    CGRect rect1 = self.frame;
//    CGRect rect2 = CGRectMake(rect1.origin.x, rect1.origin.y-rect1.size.height+kArrorHeight, rect1.size.width, rect1.size.height);
//    
//    CGRect rect3 = self.childView.frame;
//    CGRect rect4 = CGRectMake(rect3.origin.x, rect3.origin.y - kArrorHeight, rect3.size.width, rect3.size.height);
//    
//    CGRect rect5 = self.locationBtn.frame;
//    CGRect rect6 = CGRectMake(rect5.origin.x, rect5.origin.y - kHeight(78), rect5.size.width, rect5.size.height);
//    CGRect rect7 = self.balanceBtn.frame;
//    CGRect rect8 = CGRectMake(rect7.origin.x, rect7.origin.y - kHeight(78), rect7.size.width, rect7.size.height);
//    
//    [UIView animateWithDuration:0.3 animations:^{
//        self.frame = rect2;
//        self.childView.frame = rect4;
//    } completion:^(BOOL finished) {
//        
//    }];
//    [UIView animateWithDuration:0.3 delay:0.1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
//        self.locationBtn.frame = rect6;
//        self.balanceBtn.frame = rect8;
//    } completion:^(BOOL finished) {
//        
//    }];
//}
//- (void)setViewDown{
//    
//    if (self.type == ScanViewPositionDown) {
//        return;
//    }
//    self.type = ScanViewPositionDown;
//    [_topBtn setImage:[UIImage imageNamed:@"icon_up"] forState:UIControlStateNormal];
//    [_topBtn setImage:[UIImage imageNamed:@"icon_up_highlited"] forState:UIControlStateHighlighted];
//    CGRect rect1 = self.frame;
//    CGRect rect2 = CGRectMake(rect1.origin.x, rect1.origin.y+rect1.size.height-kArrorHeight, rect1.size.width, rect1.size.height);
//    
//    CGRect rect3 = self.childView.frame;
//    CGRect rect4 = CGRectMake(rect3.origin.x, rect3.origin.y + kArrorHeight, rect3.size.width, rect3.size.height);
//    
//    CGRect rect5 = self.locationBtn.frame;
//    CGRect rect6 = CGRectMake(rect5.origin.x, rect5.origin.y + kHeight(78), rect5.size.width, rect5.size.height);
//    CGRect rect7 = self.balanceBtn.frame;
//    CGRect rect8 = CGRectMake(rect7.origin.x, rect7.origin.y + kHeight(78), rect7.size.width, rect7.size.height);
//    
//   
//    [UIView animateWithDuration:0.3 animations:^{
//        self.frame = rect2;
//        self.childView.frame = rect4;
//       
//    } completion:^(BOOL finished) {
//        self.childView.hidden = YES;
//        self.locationBtn.frame = rect6;
//        self.balanceBtn.frame = rect8;
//    }];
//    
//   
//}
//
//#pragma mark --- draw rect
//
//- (void)drawRect:(CGRect)rect
//{
//    
//    [self drawInContext:UIGraphicsGetCurrentContext()];
//    
//    self.layer.shadowColor = [[UIColor blackColor] CGColor];
//    self.layer.shadowOpacity = 0.2;
//    self.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
//    
//}
//
//- (void)drawInContext:(CGContextRef)context
//{
//    
//    CGContextSetLineWidth(context, 0.1);
//    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
//    
//    [self getDrawPath:context];
//    CGContextFillPath(context);
//    
//}
//
//- (void)getDrawPath:(CGContextRef)context
//{
//    CGRect rrect = self.bounds;
//    CGFloat minx = CGRectGetMinX(rrect);
//    CGFloat miny = CGRectGetMinY(rrect);
//    CGFloat width = CGRectGetWidth(rrect);
//    
//    CGContextAddEllipseInRect(context, CGRectMake((minx - width)/2, miny, width*2, kArrorHeight*10));
//    CGContextClosePath(context);
//
//}
//
//
//
//@end
